/**
 * Copyright (c) 2025   All rights reserved.
 * <p>
 * https://www.sdl.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.sdl.controller;

import io.sdl.common.constant.Constant;
import io.sdl.common.page.PageData;
import io.sdl.common.utils.Result;
import io.sdl.common.validator.AssertUtils;
import io.sdl.common.validator.ValidatorUtils;
import io.sdl.common.validator.group.DefaultGroup;
import io.sdl.common.validator.group.UpdateGroup;
import io.sdl.dto.DictDTO;
import io.sdl.dto.SysDictDataDTO;
import io.sdl.service.SysDictDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 字典数据
 *
 * @authorDc 1211734836@qq.com
 */
@RestController
@RequestMapping("api")
@Tag(name = "字典数据")
@AllArgsConstructor
public class ApiSysDictDataController {

    @Autowired
    private final SysDictDataService sysDictDataService;



    // 获取所有字典类型
    @GetMapping("/dict/types")
    public Result<List<String>> getDictTypes() {
        return new Result<List<String>>().ok(sysDictDataService.getAllDictTypes());
    }

    // 根据类型获取字典项
    @GetMapping("/items/{type}")
    public Result<List<DictDTO>> getDictByType(@PathVariable String type) {
        return new Result<List<DictDTO>>().ok(sysDictDataService.getDictByType(type));
    }

    // 批量获取多个类型的字典
    @PostMapping("/dict/batch")
    public Result<Map<String, List<DictDTO>>> getDictBatch(@RequestBody List<String> types) {
        return new Result<Map<String, List<DictDTO>>>().ok(sysDictDataService.getDictBatch(types));
    }




}
